package com.jiubodou.myoauth2.oauth2class.my;

import com.jiubodou.myoauth2.domain.LQQS;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.HashSet;

/**
 * @ClassName MyUserDetails
 * @Description
 * @Author huyingliang
 * @Date 2023/5/6 16:26
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MyUserDetails implements UserDetails {

    private LQQS lqqs;

    private HashSet<SimpleGrantedAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities ;
    }

    @Override
    public String getPassword() {
        return lqqs.getPassword();
    }

    @Override
    public String getUsername() {
        return lqqs.getName();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
